﻿using EFCore.Context;
using IResoitory;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Resoitory
{
    //仓储层_教师表接口实现类
    public class TeacherRepository:BaseRepository<Teacher>,ITeacherRepository
    {
        private readonly EducationContext _context;

        public TeacherRepository(EducationContext context)
        {
            base.context = context;
            _context = context;
        }
        //教师登录
        public override async Task<bool> islogin(string uid, string pwd)
        {
            var result = await _context.Set<Teacher>().Where(o =>o.TeacherPhone == uid && o.TeacherPwd==pwd).FirstOrDefaultAsync();
            if (result != null)
            {
                return true;
            }
            return false;
        }
        //教师删除
        public override async Task<bool> onDelete(int id)
        {
            var result = await _context.Set<Teacher>().FindAsync(id);
            result.IsDelete = true;
            return await _context.SaveChangesAsync() > 0;
        }
        
    }
}
